public class Main {
    public static void main(String[] args) {
        System.out.println("Hello world!");
    }
}
class Solution {
    public int subarraySum(int[] nums, int k) {
        HashMap <Integer,Integer> hash = new HashMap<>();
        int ret = 0;
        int sum = 0;
        hash.put(0,1);
        for (int i = 0;i < nums.length;i++) {
            sum += nums[i];
            ret += hash.getOrDefault(sum-k,0);

            hash.put(sum,hash.getOrDefault(sum,0)+1);
        }
        return ret;
    }
}